package com.sysu.ooad.interceptor;

import java.util.Map;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
import com.sysu.ooad.entity.Student;

public class CheckStudentLoginInterceptor implements Interceptor{

	public void destroy() {
	}

	public void init() {
	}

	public String intercept(ActionInvocation invocation) throws Exception {
		Map<String, Object> session = invocation.getInvocationContext().getSession();
		Student student = (Student)session.get("student");
		if(student == null) {
			return Action.LOGIN;
		}
		else {
			return invocation.invoke();
		}
	}
}
